package com.lzq.client00.Listener;

import com.lzq.client00.Stream.StreamClient;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@EnableBinding(StreamClient.class)
public class StreamReceiver {

    @StreamListener("myMessage")
    public void msg(Object msg){
        System.out.println(msg);
    }

    //手动ack
    /*@StreamListener("myMessage")
    public void msg(Object msg,
                    @Header(name = AmqpHeaders.CHANNEL)Channel channel,
                    @Header(name = AmqpHeaders.DELIVERY_TAG) Long deliverTag) throws IOException {
        System.out.println(msg);
        channel.basicAck(deliverTag, false);
    }*/

}
